﻿<views:View x:Class="Chronos.Client.Win.Views.Common.OpenFileView"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:views="clr-namespace:Chronos.Client.Win.Views"
            xmlns:command="clr-namespace:Chronos.Client.Win.Commands"
            xmlns:converters="clr-namespace:Chronos.Client.Win.Converters"
            xmlns:controls="clr-namespace:Chronos.Client.Win.Controls"
            MinHeight="400" MinWidth="600">
    <views:View.Resources>
        <converters:BitmapToBitmapSourceConverter x:Key="BitmapToBitmapSourceConverter" />
    </views:View.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding CurrentDirectoryPath, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
                 KeyDown="OnCurrentPathTextBoxKeyDown"/>

        <ListBox Grid.Row="1" Grid.Column="0" Grid.RowSpan="3" ItemsSource="{Binding Drives}" SelectedItem="{Binding SelectedDrive}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="32" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <controls:BlurlessImage Grid.Column="0" Source="{Binding Icon, Converter={StaticResource BitmapToBitmapSourceConverter}}" />
                        <TextBlock Grid.Column="1" Text="{Binding Name}" />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <ListBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                 ItemsSource="{Binding FileSystemInfos}" SelectedItem="{Binding SelectedFileSystemInfo}"
                 ScrollViewer.VerticalScrollBarVisibility="Visible"
                 command:Event.Command="{Binding OpenSelectedFileSystemInfoCommand}"
                 command:Event.EventName="MouseDoubleClick"
                 SelectionChanged="OnFilesListBoxSelectionChanged"
                 KeyDown="OnFilesListBoxKeyDown">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="32" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <controls:BlurlessImage Grid.Column="0" Source="{Binding Icon, Converter={StaticResource BitmapToBitmapSourceConverter}}"/>
                        <TextBlock Grid.Column="1" Text="{Binding Name}"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Name, Mode=OneWay}" IsEnabled="False" />

        <ComboBox Grid.Row="3" Grid.Column="1" ItemsSource="{Binding Filters}" SelectedItem="{Binding SelectedFilter}" DisplayMemberPath="DisplayName" />

        <ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" Style="{DynamicResource PanelContentControl}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Button Grid.Column="1" Content="Open"
                        command:Event.Command="{Binding OpenFileSystemInfoCommand}" />
                <Button Grid.Column="2" Content="Cancel" IsCancel="True" />
            </Grid>
        </ContentControl>
    </Grid>
</views:View>
